-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] last_ordered_products: improved sale and purchase by adding this module #654
base: 18.0
Are you sure you want to change the base?
Conversation
…s module - In product_product and product_template override method name_search to get last ordered time for selected customer. - Implemented functions to get last_sold_products and last_purchased_products based on customer's invoice and vendor's bill. - Added compute method to get last_order_time and time difference string. - Updated context in sale_order, purchase_order and account_move to get order_type and partner_id in context - In catalog, to re-organize displayed information inherited sale_order and sale_order_line, override some methods to get sale_uom of order line - In catalog, to re-organize displayed information inherited product_view_kanban_catalog view - Extend ProductCatalogOrderLine to get sale_uom in catalog - Patch ProductCatalogKanbanRecord to get information as per the requirement - Extend Autocomplete to get time difference string in product dropdown - Patch ProductLabelSectionAndNoteFieldAutocomplete to override function which will be used to get time difference string
…s module - Optimizing code - Try to remove unnecessary code
…s module - Removed unnecessary code - In product catalog also products will be sorted based on invoice creation date
- testcases added
- web_tour added to show flow of module
2795104
to
8f87feb
Compare
- Improved code by removing unnecessary code
94acb7e
to
9e01f9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work!!
Code look fragile and can be easily break. We should not rely that much on context instead we should add something robust and context should be last option and we should not make feature that can be used individually by single app in dependent of multiple main apps
Have a nice day!
{ | ||
'name': "Last Ordered Products", | ||
'version': '1.0', | ||
'depends': ['sale_management', 'purchase', 'stock'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not make a module depending on three major app because even if I want to use this feature only in Sale app it will install inventory and purchase module
So, I was thinking something generic only depending on product app which will contain helper methods and fields to compute those date and if needed create other two modules to call those methods or override them
What do you think?
if self.env.context.get('active_model') == 'sale.order.line': | ||
partner_id = self.env['sale.order'].browse(self.env.context.get('order_id')).partner_id.id | ||
order_type = 'sale' | ||
elif self.env.context.get('active_model') == 'purchase.order.line': | ||
partner_id = self.env['purchase.order'].browse(self.env.context.get('order_id')).partner_id.id | ||
order_type = 'purchase' | ||
elif self.env.context.get('active_model') == 'account.journal': | ||
active_id = self.env.context.get('active_id') | ||
if active_id: | ||
order_type = self.env['account.journal'].browse(active_id).type | ||
partner_id = self.env.context.get('partner_id') or self.env.context.get('default_partner_id') | ||
else: | ||
partner_id = self.env.context.get('partner_id') | ||
order_type = self.env.context.get('order_type') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not rely on context too much instead add something robust to compute these fields
last ordered time for selected customer.
based on customer's invoice and vendor's bill.
order_type and partner_id in context
sale_order_line, override some methods to get sale_uom of order line
product_view_kanban_catalog view
which will be used to get time difference string